//
//  CarMallIconBtnV.m
//  carcareIOS
//
//  Created by 王然 on 16/8/17.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "CarMallIconBtnV.h"

#define View_EdgeInset_W (3)
@interface CarMallIconBtnV()

@property (nonatomic , strong) UIImageView * iconIV;

@property (nonatomic , copy) void(^btnClick)();

@end

@implementation CarMallIconBtnV
- (instancetype)initWithFrameXY:(CGPoint)point iconImage:(UIImage *)iconImage click:(void(^)())click
{
    self = [super initWithFrame:CGRectMake(point.x - View_EdgeInset_W, point.y - View_EdgeInset_W, iconImage.size.width  + View_EdgeInset_W * 2, iconImage.size.height + 3 * 2)];
    if (self) {
        
        if (click) self.btnClick = click;
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    self.iconIV = [[UIImageView imageViewWithFrame:CGRectMake(View_EdgeInset_W, View_EdgeInset_W, self.width - View_EdgeInset_W * 2, self.height - View_EdgeInset_W * 2) image:nil] setupOnView:self];
    
    [[UIButton buttonEmptyWithFrame:self.bounds click:^{
        if (self.btnClick) self.btnClick();
    } ] setupOnView:self];
}
- (void)reloadLBSModel:(LBSModel *)model
{
    if(model.isFit && [model.mallIconStr isNotNil])[self.iconIV setImage:ImageNamed(model.mallIconStr)];
    [self setHidden:!model.isFit];
}

@end
